﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using DevExpress.Utils;

namespace BanHangCshap.DanhMuc.gkhtdl63
{
    public partial class frmChitietVattuCaduan : Form
    {
        long xgId_Duan;
        public frmChitietVattuCaduan(long xlId_Duan)
        {
            this.xgId_Duan = xlId_Duan;
            InitializeComponent();
        }

        private Class.gkhtdl63.BLL.DuanBLL xgDuanaBLL = new BanHangCshap.Class.gkhtdl63.BLL.DuanBLL();
        DataTable xgDTTonghop = new DataTable();

        private void frmChitietVattuCaduan_Load(object sender, EventArgs e)
        {
            Class.gkhtdl63.BLL.DuanBLL xlDuanBLL = new BanHangCshap.Class.gkhtdl63.BLL.DuanBLL();
            gcTonghop.DataSource = xlDuanBLL.Duan_LayTonghopVattu(xgId_Duan);
            gcChitiet.DataSource = xlDuanBLL.Duan_LayChitietVattu(xgId_Duan);
        }

        private void btnDong2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnInChitiet_Click(object sender, EventArgs e)
        {
            DevExpress.Utils.WaitDialogForm xlDG = new DevExpress.Utils.WaitDialogForm("Đang load dữ liệu...", "Xin chờ trong giây lát.");
            Report.gkhtdl63.frmMainRPTS frm = new BanHangCshap.Report.gkhtdl63.frmMainRPTS();
            Report.gkhtdl63.MyRPT.Duan.rptInDuanA4 rpt = new BanHangCshap.Report.gkhtdl63.MyRPT.Duan.rptInDuanA4();
            Class.gkhtdl63.BLL.DuanBLL xlDuanBLL = new BanHangCshap.Class.gkhtdl63.BLL.DuanBLL(); 
            rpt.DataSource = xlDuanBLL.Duan_LayChitietVattu(xgId_Duan);
            frm.SetReport(rpt);
            xlDG.Close();
            frm.ShowDialog();
        }

        private void InA4(bool xlInChitietOrTonghop)
        {
            WaitDialogForm xlDG = new WaitDialogForm("Đang load dữ liệu...", "Xin chờ trong giây lát.");
            Report.gkhtdl63.frmMainRPTS frm = new BanHangCshap.Report.gkhtdl63.frmMainRPTS();

            if (xlInChitietOrTonghop)
            {
                Report.gkhtdl63.MyRPT.Duan.rptInDuanA4 rpt = new BanHangCshap.Report.gkhtdl63.MyRPT.Duan.rptInDuanA4();
                rpt.DataSource = xgDuanaBLL.Duan_LayChitietVattu(xgId_Duan);
                frm.SetReport(rpt);
            }
            else
            {
                Report.gkhtdl63.MyRPT.Duan.rptDuan_XemtonghopVattu rpt = new BanHangCshap.Report.gkhtdl63.MyRPT.Duan.rptDuan_XemtonghopVattu();
                rpt.DataSource = xgDuanaBLL.Duan_LayTonghopVattu(xgId_Duan);
                frm.SetReport(rpt);
            }

            xlDG.Close();
            frm.ShowDialog();
        }

        private void InA5(bool xlInChitietOrTonghop)
        {
            WaitDialogForm xlDG = new WaitDialogForm("Đang load dữ liệu...", "Xin chờ trong giây lát.");
            Report.gkhtdl63.frmMainRPTS frm = new BanHangCshap.Report.gkhtdl63.frmMainRPTS();

            if (xlInChitietOrTonghop)
            {
                //Report.gkhtdl63.MyRPT.Duan.rptInDuanA4 rpt = new BanHangCshap.Report.gkhtdl63.MyRPT.Duan.rptInDuanA4();
                //rpt.DataSource = xgDuanaBLL.Duan_LayChitietVattu(xgIdDuan);
                //frm.SetReport(rpt);
            }
            else
            {
                Report.gkhtdl63.MyRPT.Duan.rptDuan_XemtonghopVattuA5 rpt = new BanHangCshap.Report.gkhtdl63.MyRPT.Duan.rptDuan_XemtonghopVattuA5();
                rpt.DataSource = xgDuanaBLL.Duan_LayTonghopVattu(xgId_Duan);
                frm.SetReport(rpt);
            }

            xlDG.Close();
            frm.ShowDialog();
        }

        private void btnInTonghopVatu_Click(object sender, EventArgs e)
        {
            InA4(false);
        }

        private void btnInTonghopVatuA4_Click(object sender, EventArgs e)
        {
            InA4(false);
        }

        private void btnInTonghopVatuA5_Click(object sender, EventArgs e)
        {
            InA5(false);
        }


    }
}
